<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>fastText: /data/users/cpuhrsch/fbsource/fbcode/deeplearning/fastText/src/qmatrix.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="favicon.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">fastText
   &#160;<span id="projectnumber">d00d36476b15</span>
   </div>
   <div id="projectbrief">Fast text processing tool/library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('qmatrix_8h_source.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">qmatrix.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="qmatrix_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="preprocessor">#ifndef FASTTEXT_QMATRIX_H</span></div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="preprocessor">#define FASTTEXT_QMATRIX_H</span></div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;</div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor">#include &lt;cstdint&gt;</span></div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="preprocessor">#include &lt;istream&gt;</span></div><div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="preprocessor">#include &lt;ostream&gt;</span></div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;</div><div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="preprocessor">#include &lt;vector&gt;</span></div><div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="preprocessor">#include &lt;memory&gt;</span></div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;</div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="real_8h.html">real.h</a>&quot;</span></div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;</div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="matrix_8h.html">matrix.h</a>&quot;</span></div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="vector_8h.html">vector.h</a>&quot;</span></div><div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;</div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="productquantizer_8h.html">productquantizer.h</a>&quot;</span></div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;</div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacefasttext.html">fasttext</a> {</div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;</div><div class="line"><a name="l00029"></a><span class="lineno"><a class="line" href="classfasttext_1_1QMatrix.html">   29</a></span>&#160;<span class="keyword">class </span><a class="code" href="classfasttext_1_1QMatrix.html">QMatrix</a> {</div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;  <span class="keyword">private</span>:</div><div class="line"><a name="l00031"></a><span class="lineno"><a class="line" href="classfasttext_1_1QMatrix.html#a6c62644a138ed88863088dcdeb32dbd7">   31</a></span>&#160;    std::unique_ptr&lt;ProductQuantizer&gt; <a class="code" href="classfasttext_1_1QMatrix.html#a6c62644a138ed88863088dcdeb32dbd7">pq_</a>;</div><div class="line"><a name="l00032"></a><span class="lineno"><a class="line" href="classfasttext_1_1QMatrix.html#a8203216a4cb2b721697f7dc2b509f25a">   32</a></span>&#160;    std::unique_ptr&lt;ProductQuantizer&gt; <a class="code" href="classfasttext_1_1QMatrix.html#a8203216a4cb2b721697f7dc2b509f25a">npq_</a>;</div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;</div><div class="line"><a name="l00034"></a><span class="lineno"><a class="line" href="classfasttext_1_1QMatrix.html#acc957d3d66b58cb9381f6a0556096c93">   34</a></span>&#160;    uint8_t* <a class="code" href="classfasttext_1_1QMatrix.html#acc957d3d66b58cb9381f6a0556096c93">codes_</a>;</div><div class="line"><a name="l00035"></a><span class="lineno"><a class="line" href="classfasttext_1_1QMatrix.html#a17f22153d042c64052a3468faec70fce">   35</a></span>&#160;    uint8_t* <a class="code" href="classfasttext_1_1QMatrix.html#a17f22153d042c64052a3468faec70fce">norm_codes_</a>;</div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;</div><div class="line"><a name="l00037"></a><span class="lineno"><a class="line" href="classfasttext_1_1QMatrix.html#aadc6e4d399442555f3c2993b97285143">   37</a></span>&#160;    <span class="keywordtype">bool</span> <a class="code" href="classfasttext_1_1QMatrix.html#aadc6e4d399442555f3c2993b97285143">qnorm_</a>;</div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;</div><div class="line"><a name="l00039"></a><span class="lineno"><a class="line" href="classfasttext_1_1QMatrix.html#ad2457490bb9a531740187fffb63cace2">   39</a></span>&#160;    int64_t <a class="code" href="classfasttext_1_1QMatrix.html#ad2457490bb9a531740187fffb63cace2">m_</a>;</div><div class="line"><a name="l00040"></a><span class="lineno"><a class="line" href="classfasttext_1_1QMatrix.html#a54082c819b9939e2d49fc0733a609cea">   40</a></span>&#160;    int64_t <a class="code" href="classfasttext_1_1QMatrix.html#a54082c819b9939e2d49fc0733a609cea">n_</a>;</div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;</div><div class="line"><a name="l00042"></a><span class="lineno"><a class="line" href="classfasttext_1_1QMatrix.html#a4a69f60ba96c0b1a9da22c3951eca759">   42</a></span>&#160;    int32_t <a class="code" href="classfasttext_1_1QMatrix.html#a4a69f60ba96c0b1a9da22c3951eca759">codesize_</a>;</div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;</div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;  <span class="keyword">public</span>:</div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;</div><div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;    <a class="code" href="classfasttext_1_1QMatrix.html#a976442aaed5b1afee2f2cd4473c0d62b">QMatrix</a>();</div><div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;    <a class="code" href="classfasttext_1_1QMatrix.html#a976442aaed5b1afee2f2cd4473c0d62b">QMatrix</a>(<span class="keyword">const</span> <a class="code" href="classfasttext_1_1Matrix.html">Matrix</a>&amp;, int32_t, <span class="keywordtype">bool</span>);</div><div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;    <a class="code" href="classfasttext_1_1QMatrix.html#a7de6d212bec1c4028ee30e968b5d030d">~QMatrix</a>();</div><div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;</div><div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;    int64_t <a class="code" href="classfasttext_1_1QMatrix.html#a16350455c02cf5f00175b1b0c6a310cd">getM</a>() <span class="keyword">const</span>;</div><div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;    int64_t <a class="code" href="classfasttext_1_1QMatrix.html#ad969042dfc46a64e386f12616a4d6bcb">getN</a>() <span class="keyword">const</span>;</div><div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;</div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classfasttext_1_1QMatrix.html#a0e4d84be1c6cd0cbfc4568f905961017">quantizeNorm</a>(<span class="keyword">const</span> <a class="code" href="classfasttext_1_1Vector.html">Vector</a>&amp;);</div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classfasttext_1_1QMatrix.html#ab9ae1914dc1b72e305880a8c22626afc">quantize</a>(<span class="keyword">const</span> <a class="code" href="classfasttext_1_1Matrix.html">Matrix</a>&amp;);</div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;</div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classfasttext_1_1QMatrix.html#ad8f153a45f69530aeef171bebbce93fc">addToVector</a>(<a class="code" href="classfasttext_1_1Vector.html">Vector</a>&amp; x, int32_t t) <span class="keyword">const</span>;</div><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;    <a class="code" href="namespacefasttext.html#a7afdad102f318271c14154b8e65e5ea3">real</a> <a class="code" href="classfasttext_1_1QMatrix.html#ad1671bceb60d87492b662331cc084c56">dotRow</a>(<span class="keyword">const</span> <a class="code" href="classfasttext_1_1Vector.html">Vector</a>&amp;, int64_t) <span class="keyword">const</span>;</div><div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;</div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classfasttext_1_1QMatrix.html#a00267b43ee5eefc92948c654fb9fc9f1">save</a>(std::ostream&amp;);</div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;    <span class="keywordtype">void</span> <a class="code" href="classfasttext_1_1QMatrix.html#a03c039b81b5aaed30d95149de9379998">load</a>(std::istream&amp;);</div><div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;};</div><div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;</div><div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;}</div><div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;</div><div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;<span class="preprocessor">#endif</span></div><div class="ttc" id="classfasttext_1_1QMatrix_html_a4a69f60ba96c0b1a9da22c3951eca759"><div class="ttname"><a href="classfasttext_1_1QMatrix.html#a4a69f60ba96c0b1a9da22c3951eca759">fasttext::QMatrix::codesize_</a></div><div class="ttdeci">int32_t codesize_</div><div class="ttdef"><b>Definition:</b> qmatrix.h:42</div></div>
<div class="ttc" id="classfasttext_1_1QMatrix_html_a16350455c02cf5f00175b1b0c6a310cd"><div class="ttname"><a href="classfasttext_1_1QMatrix.html#a16350455c02cf5f00175b1b0c6a310cd">fasttext::QMatrix::getM</a></div><div class="ttdeci">int64_t getM() const</div><div class="ttdef"><b>Definition:</b> qmatrix.cc:83</div></div>
<div class="ttc" id="classfasttext_1_1QMatrix_html_ad2457490bb9a531740187fffb63cace2"><div class="ttname"><a href="classfasttext_1_1QMatrix.html#ad2457490bb9a531740187fffb63cace2">fasttext::QMatrix::m_</a></div><div class="ttdeci">int64_t m_</div><div class="ttdef"><b>Definition:</b> qmatrix.h:39</div></div>
<div class="ttc" id="classfasttext_1_1QMatrix_html_acc957d3d66b58cb9381f6a0556096c93"><div class="ttname"><a href="classfasttext_1_1QMatrix.html#acc957d3d66b58cb9381f6a0556096c93">fasttext::QMatrix::codes_</a></div><div class="ttdeci">uint8_t * codes_</div><div class="ttdef"><b>Definition:</b> qmatrix.h:34</div></div>
<div class="ttc" id="namespacefasttext_html"><div class="ttname"><a href="namespacefasttext.html">fasttext</a></div><div class="ttdef"><b>Definition:</b> args.cc:17</div></div>
<div class="ttc" id="classfasttext_1_1QMatrix_html_ad1671bceb60d87492b662331cc084c56"><div class="ttname"><a href="classfasttext_1_1QMatrix.html#ad1671bceb60d87492b662331cc084c56">fasttext::QMatrix::dotRow</a></div><div class="ttdeci">real dotRow(const Vector &amp;, int64_t) const</div><div class="ttdef"><b>Definition:</b> qmatrix.cc:72</div></div>
<div class="ttc" id="classfasttext_1_1Vector_html"><div class="ttname"><a href="classfasttext_1_1Vector.html">fasttext::Vector</a></div><div class="ttdef"><b>Definition:</b> vector.h:23</div></div>
<div class="ttc" id="classfasttext_1_1QMatrix_html_a17f22153d042c64052a3468faec70fce"><div class="ttname"><a href="classfasttext_1_1QMatrix.html#a17f22153d042c64052a3468faec70fce">fasttext::QMatrix::norm_codes_</a></div><div class="ttdeci">uint8_t * norm_codes_</div><div class="ttdef"><b>Definition:</b> qmatrix.h:35</div></div>
<div class="ttc" id="classfasttext_1_1QMatrix_html_ab9ae1914dc1b72e305880a8c22626afc"><div class="ttname"><a href="classfasttext_1_1QMatrix.html#ab9ae1914dc1b72e305880a8c22626afc">fasttext::QMatrix::quantize</a></div><div class="ttdeci">void quantize(const Matrix &amp;)</div><div class="ttdef"><b>Definition:</b> qmatrix.cc:49</div></div>
<div class="ttc" id="classfasttext_1_1QMatrix_html_a00267b43ee5eefc92948c654fb9fc9f1"><div class="ttname"><a href="classfasttext_1_1QMatrix.html#a00267b43ee5eefc92948c654fb9fc9f1">fasttext::QMatrix::save</a></div><div class="ttdeci">void save(std::ostream &amp;)</div><div class="ttdef"><b>Definition:</b> qmatrix.cc:91</div></div>
<div class="ttc" id="classfasttext_1_1QMatrix_html_a7de6d212bec1c4028ee30e968b5d030d"><div class="ttname"><a href="classfasttext_1_1QMatrix.html#a7de6d212bec1c4028ee30e968b5d030d">fasttext::QMatrix::~QMatrix</a></div><div class="ttdeci">~QMatrix()</div><div class="ttdef"><b>Definition:</b> qmatrix.cc:34</div></div>
<div class="ttc" id="real_8h_html"><div class="ttname"><a href="real_8h.html">real.h</a></div></div>
<div class="ttc" id="matrix_8h_html"><div class="ttname"><a href="matrix_8h.html">matrix.h</a></div></div>
<div class="ttc" id="classfasttext_1_1QMatrix_html_ad969042dfc46a64e386f12616a4d6bcb"><div class="ttname"><a href="classfasttext_1_1QMatrix.html#ad969042dfc46a64e386f12616a4d6bcb">fasttext::QMatrix::getN</a></div><div class="ttdeci">int64_t getN() const</div><div class="ttdef"><b>Definition:</b> qmatrix.cc:87</div></div>
<div class="ttc" id="productquantizer_8h_html"><div class="ttname"><a href="productquantizer_8h.html">productquantizer.h</a></div></div>
<div class="ttc" id="classfasttext_1_1QMatrix_html_a8203216a4cb2b721697f7dc2b509f25a"><div class="ttname"><a href="classfasttext_1_1QMatrix.html#a8203216a4cb2b721697f7dc2b509f25a">fasttext::QMatrix::npq_</a></div><div class="ttdeci">std::unique_ptr&lt; ProductQuantizer &gt; npq_</div><div class="ttdef"><b>Definition:</b> qmatrix.h:32</div></div>
<div class="ttc" id="vector_8h_html"><div class="ttname"><a href="vector_8h.html">vector.h</a></div></div>
<div class="ttc" id="namespacefasttext_html_a7afdad102f318271c14154b8e65e5ea3"><div class="ttname"><a href="namespacefasttext.html#a7afdad102f318271c14154b8e65e5ea3">fasttext::real</a></div><div class="ttdeci">float real</div><div class="ttdef"><b>Definition:</b> real.h:15</div></div>
<div class="ttc" id="classfasttext_1_1Matrix_html"><div class="ttname"><a href="classfasttext_1_1Matrix.html">fasttext::Matrix</a></div><div class="ttdef"><b>Definition:</b> matrix.h:23</div></div>
<div class="ttc" id="classfasttext_1_1QMatrix_html_aadc6e4d399442555f3c2993b97285143"><div class="ttname"><a href="classfasttext_1_1QMatrix.html#aadc6e4d399442555f3c2993b97285143">fasttext::QMatrix::qnorm_</a></div><div class="ttdeci">bool qnorm_</div><div class="ttdef"><b>Definition:</b> qmatrix.h:37</div></div>
<div class="ttc" id="classfasttext_1_1QMatrix_html_ad8f153a45f69530aeef171bebbce93fc"><div class="ttname"><a href="classfasttext_1_1QMatrix.html#ad8f153a45f69530aeef171bebbce93fc">fasttext::QMatrix::addToVector</a></div><div class="ttdeci">void addToVector(Vector &amp;x, int32_t t) const</div><div class="ttdef"><b>Definition:</b> qmatrix.cc:64</div></div>
<div class="ttc" id="classfasttext_1_1QMatrix_html_a03c039b81b5aaed30d95149de9379998"><div class="ttname"><a href="classfasttext_1_1QMatrix.html#a03c039b81b5aaed30d95149de9379998">fasttext::QMatrix::load</a></div><div class="ttdeci">void load(std::istream &amp;)</div><div class="ttdef"><b>Definition:</b> qmatrix.cc:104</div></div>
<div class="ttc" id="classfasttext_1_1QMatrix_html_a6c62644a138ed88863088dcdeb32dbd7"><div class="ttname"><a href="classfasttext_1_1QMatrix.html#a6c62644a138ed88863088dcdeb32dbd7">fasttext::QMatrix::pq_</a></div><div class="ttdeci">std::unique_ptr&lt; ProductQuantizer &gt; pq_</div><div class="ttdef"><b>Definition:</b> qmatrix.h:31</div></div>
<div class="ttc" id="classfasttext_1_1QMatrix_html"><div class="ttname"><a href="classfasttext_1_1QMatrix.html">fasttext::QMatrix</a></div><div class="ttdef"><b>Definition:</b> qmatrix.h:29</div></div>
<div class="ttc" id="classfasttext_1_1QMatrix_html_a976442aaed5b1afee2f2cd4473c0d62b"><div class="ttname"><a href="classfasttext_1_1QMatrix.html#a976442aaed5b1afee2f2cd4473c0d62b">fasttext::QMatrix::QMatrix</a></div><div class="ttdeci">QMatrix()</div><div class="ttdef"><b>Definition:</b> qmatrix.cc:17</div></div>
<div class="ttc" id="classfasttext_1_1QMatrix_html_a0e4d84be1c6cd0cbfc4568f905961017"><div class="ttname"><a href="classfasttext_1_1QMatrix.html#a0e4d84be1c6cd0cbfc4568f905961017">fasttext::QMatrix::quantizeNorm</a></div><div class="ttdeci">void quantizeNorm(const Vector &amp;)</div><div class="ttdef"><b>Definition:</b> qmatrix.cc:41</div></div>
<div class="ttc" id="classfasttext_1_1QMatrix_html_a54082c819b9939e2d49fc0733a609cea"><div class="ttname"><a href="classfasttext_1_1QMatrix.html#a54082c819b9939e2d49fc0733a609cea">fasttext::QMatrix::n_</a></div><div class="ttdeci">int64_t n_</div><div class="ttdef"><b>Definition:</b> qmatrix.h:40</div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="qmatrix_8h.html">qmatrix.h</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
</body>
</html>
